<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>lwIP network interface integration library: Optimization of lwIP-network-interface-integration</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="cypress_logo.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">lwIP network interface integration library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__group__optimization__config.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle"><div class="title">Optimization of lwIP-network-interface-integration</div></div>
</div><!--header-->
<div class="contents">
<p >For PSoC 6 MCU family of chips and Wi-Fi/BT connectivity chips that have limited flash and RAM footprint, there is a need to optimize the various connectivity middleware components to fit into kits that use these chips. </p>
<p >Examples include CY8CPROTO-062S3-4343W that has 512KB flash and 256KB SRAM.</p>
<p >The default lwIP and Mbed TLS configuration files bundled with the Wi-Fi Middleware Core have serveral features enabled for typical embedded IoT use cases. However, not all of these parameters are pertinent for every use case. The approach is to provide a set of such tunables that can be turned off in order to conserve memory, thus enabling the firmware to fit into the available flash and RAM.</p>
<p >The lwIP parameters are defined in <a href="https://github.com/infineon/wifi-mw-core/configs/lwipopts.h">lwipopts.h</a>. Modify this header file to customize the lwIP parameters defined in the table below.</p>
<p >For Mbed TLS, a default config.h file is bundled with the Mbed TLS library. It is not recommended to modify the default config header file; you should modify the user-defined <a href="https://github.com/infineon/wifi-mw-core/configs/mbedtls_user_config.h">mbedtls_user_config.h</a> file bundled with Wi-Fi Middleware Core. The approach is to update the mbedtls_user_config.h file to override the default behavior defined in the config.h file. Note that this mbedtls_user_config.h file has been tuned with several options to conserve memory for common embedded IoT use cases from the default config.h file, amounting to approx. 16KB of code memory savings. The following recommendations are additional optimizations.</p>
<p >The configurations listed below provide savings to one of the following: code memory, static RAM, or heap memory. Some parameters may save code memory at the cost of heap/SRAM.</p>
<p >The savings are mentioned in kilobytes, and are an estimate (computed in DEBUG build). Actual values may differ from the numbers provided below.</p>
<h1><a class="anchor" id="optim_mbedTLS"></a>
Mbed TLS configuration parameters</h1>
<table class="doxtable">
<tr>
<th>Configuration Parameter </th><th>Savings </th><th>Type of memory </th><th>Action needed </th><th>Notes  </th></tr>
<tr>
<td>MBEDTLS_SSL_SRV_C </td><td>~16KB </td><td>Code memory </td><td nowrap="nowrap">Default:Enabled.<br  />
To disable, <code>#undef MBEDTLS_SSL_SRV_C</code> in mbedtls_user_config.h </td><td>Enables the SSL/TLS server code. This configuration is used when device is expected to function as an SSL/TLS server and can be disabled if only run SSL/TLS client mode is required.  </td></tr>
<tr>
<td>MBEDTLS_SSL_CLI_C </td><td>~14KB </td><td>Code memory </td><td>Default:Enabled. <br  />
To disable, <code>#undef MBEDTLS_SSL_CLI_C</code> in mbedtls_user_config.h </td><td><p class="starttd">Enables the SSL/TLS client code. This configuration is used when device is expected to function as an SSL/TLS client and can be disabled if only run SSL/TLS server mode is required. </p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>MBEDTLS_AES_ROM_TABLES </td><td>~8.5KB </td><td>Static RAM </td><td>Default:Disabled. <br  />
To enable, <code>#define MBEDTLS_AES_ROM_TABLES</code> in mbedtls_user_config.h </td><td><p class="starttd">Enable this parameter to use precomputed AES tables stored in ROM. When disabled, the AES tables are generated in RAM at runtime. It comes at the cost of additional code memory and potentially degraded performance if ROM access is slower than RAM access. </p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>MBEDTLS_SSL_IN_CONTENT_LEN </td><td>~8KB </td><td>Heap memory </td><td>Default:16384. <br  />
To override, <code>#define MBEDTLS_SSL_IN_CONTENT_LEN 8192</code> in mbedtls_user_config.h </td><td><p class="starttd">Maximum length (in bytes) of incoming plaintext fragments. This determines the size of the incoming TLS I/O buffer in such a way that it is capable of holding the specified amount of plaintext data, regardless of the protection mechanism used. If it is known that the use case running on the device needs smaller-sized buffers (both for handshake and data), this parameter can be tuned to a lower value. The recommended value of 8192 is indicative and can be set lower/upper depending on the end use case. </p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>MBEDTLS_SSL_OUT_CONTENT_LEN </td><td>~8KB </td><td>Heap memory </td><td>Default:16384. <br  />
To override, <code>#define MBEDTLS_SSL_OUT_CONTENT_LEN 8192</code> in mbedtls_user_config.h </td><td><p class="starttd">Maximum length (in bytes) of incoming plaintext fragments. This determines the size of the outgoing TLS I/O buffer in such a way that it is capable of holding the specified amount of plaintext data, regardless of the protection mechanism used. If it is known that the use case running on the device needs smaller-sized buffers (both for handshake and data), this parameter can be tuned to a lower value. The recommended value of 8192 is indicative and can be set lower/upper depending on the end use case. </p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>MBEDTLS_CHACHA20_C <br  />
 MBEDTLS_CHACHAPOLY_C <br  />
 MBEDTLS_POLY1305_C </td><td>~4KB </td><td>Code memory </td><td>Default:Enabled. <br  />
To disable, <code>#undef MBEDTLS_CHACHA20_C <br  />
#undef MBEDTLS_CHACHAPOLY_C<br  />
#undef MBEDTLS_POLY1305_C</code> in mbedtls_user_config.h </td><td><p class="starttd">These options enable support for ChaCha20 stream cipher, ChaCha20-Poly1305 AEAD algorithm and Poly1305 MAC algorithm respectively. These are generally used for HomeKit ADK library features. </p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>MBEDTLS_CAMELLIA_SMALL_MEMORY </td><td>~1KB </td><td>Code memory </td><td>Default:Disabled. <br  />
To enable, <code>#define MBEDTLS_CAMELLIA_SMALL_MEMORY</code> in mbedtls_user_config.h </td><td><p class="starttd">This parameter is used to save code memory by using a small footprint Camellia implementation. Mutually exclusive to MBEDTLS_CAMELLIA_C below. </p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>MBEDTLS_CAMELLIA_C </td><td>~7.5KB </td><td>Code memory </td><td>Default:Enabled. <br  />
To enable, <code>#define MBEDTLS_CAMELLIA_C</code> in mbedtls_user_config.h </td><td><p class="starttd">This parameter enables support for the fully featured Camellia cipher suites. Mutually exclusive to MBEDTLS_CAMELLIA_SMALL_MEMORY above. </p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>MBEDTLS_SHA256_SMALLER </td><td>~1.6KB </td><td>Code memory </td><td>Default:Disabled. <br  />
To enable, <code>#define MBEDTLS_SHA256_SMALLER</code> in mbedtls_user_config.h </td><td><p class="starttd">Enabling this option saves code space but at the expense of performance. For example, on Cortex-M4 it reduces the size by approx 2KB for a performance hit of about 30%. </p>
<p class="endtd"></p>
</td></tr>
</table>
<h1><a class="anchor" id="optim_lwip"></a>
lwIP configuration parameters</h1>
<table class="doxtable">
<tr>
<th>Configuration Parameter </th><th>Savings </th><th>Type of memory </th><th>Action needed </th><th><p class="starttd">Notes </p>
<p class="endtd"></p>
</th></tr>
<tr>
<td rowspan="2">LWIP_IPV6 </td><td>~27KB </td><td>Code memory </td><td rowspan="2">Default:Enabled. <br  />
To disable, <code>#define LWIP_IPV6 0</code> in lwipopts.h </td><td rowspan="2">This parameter enables support for IPv6.  </td></tr>
<tr>
<td>~3.3KB </td><td><p class="starttd">Static RAM </p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>LWIP_STATS </td><td>~1.4KB </td><td>Code memory </td><td>Default:Disabled. <br  />
To enable, <code>#define LWIP_STATS 1</code> in lwipopts.h </td><td>Enabling this parameter, results in lwIP collecting debug and other statistic info. Enabled by default in DEBUG mode and disabled in RELEASE mode.  </td></tr>
</table>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>lwIP network interface integration library</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
</body>
</html>
